package exam.service.impl;

import exam.bean.PermissionGroupInfo;
import exam.dao.PermissionGroupDao;
import exam.service.IPermissionGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class PermissionGroupServiceImpl implements IPermissionGroupService {
    @Autowired
    PermissionGroupDao permissionGroupDao;

    @Override
    public int insertInfo(PermissionGroupInfo permissionGroupInfo) {
        return permissionGroupDao.insertInfo(permissionGroupInfo);
    }

    @Override
    public int updateInfo(PermissionGroupInfo permissionGroupInfo) {
        return permissionGroupDao.updateInfo(permissionGroupInfo);
    }

    @Override
    public int deleteInfo(int id) {
        return permissionGroupDao.deleteInfo(id);
    }

    @Override
    public List<PermissionGroupInfo> selectInfo() {
        return permissionGroupDao.selectInfo(null);
    }

    @Override
    public PermissionGroupInfo selectInfoById(int id) {
        Map<String,Object> queryMap = new HashMap<>();
        queryMap.put("id",id);
        List<PermissionGroupInfo> re= permissionGroupDao.selectInfo(queryMap);
        if( re != null && re.size() > 0){
            return re.get(0);
        }else{
            return null;
        }
    }
}
